package likou.offer;

/**
 * @Info:
 * @Author: 唐小尊
 * @Date: 2020/8/31  19:54
 */
public class _58_1 {
    public static void main(String[] args) {
        System.out.println(reverseWords("a good   example"));
    }
    public static String reverseWords(String s) {
        s = s.trim();
        s = s.replaceAll(" +", " ");
        String[] daans = s.split(" ");
        StringBuilder daan = new StringBuilder();
        for(int i = daans.length-1 ;i>=0;i--){
            daan.append(daans[i]).append(" ");
        }
        return String.valueOf(daan);
    }
}
